class Solution {
public:
    int similarPairs(vector<string>& words)
    {
        int ans = 0;
        for (int i = 0; i < words.size(); i++)
        {
            for (int j = i + 1; j < words.size(); j++)
            {
                set<char> s1, s2;
                for (auto e : words[i]) s1.insert(e);
                for (auto e : words[j]) s2.insert(e);
                if (s1 == s2) ans++;
            }
        }
        return ans;
    }
};